<template>
  <div class="particulars">
    <v-detail :detailData="inputData"
              :inputConfig="inputConfig"
              :rules="rules"
              ref="input"></v-detail>
  </div>
</template>

<script>
import detail from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "AsnDetail",
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object
    }
  },
  data () {
    return {
      addflag: false,
      whseidflag: false,
      rules: {
        listname: [
          { required: true, trigger: 'blur' },
        ]
      },
      showNewBtn: true
    }
  },
  computed: {
    inputConfig () {
      return [
        [
          {
            type: "input",
            label: this.$t('config.listName'),
            props: "listname",
          },
          {
            type: "textarea",
            label: this.$t('common.desc'),
            props: "description",
          },
        ],
        [
          {
            type: "select",
            label: this.$t('config.parentlistName'),
            props: "parentlist",
            options: this.getOptions(`queryParentlist/${this.$store.state.wms}`),
          },
          {
            type: "select",
            label: this.$t('config.parentCode'),
            props: "parentcode",
            options: this.getOptions('querycodeLkup/ACTIVTYPE'),
          },
        ],
        [
          {
            type: "textarea",
            label: this.$t('config.language'),
            props: "language",
          },
          {
            type: "checkbox",
            label: this.$t('config.cropCode'),
            props: "enterprisecode",
            disabled: this.whseidflag
          },
          {
            type: "checkbox",
            label: this.$t('config.outUse'),
            props: "usedexternallyindicator",
          },
        ]
      ]
    }
  },
  methods: {},
  mounted () {
    if (this.$store.state.wms.toUpperCase().includes('WMWHSE')) {
      //仓库级
      this.addflag = this.whseidflag = true;
    } else {
      this.inputData.enterprisecode = "1";
    }
  },
  watch: {
    inputData: {
      handler (newVal) {
        if (newVal.enterprisecode === 0) {
          this.showNewBtn = false
        } else {
          this.showNewBtn = true
        }
        this.$parent.initshowNewBtn()
      },
      deep: true,
      immediate: false,

    }
  },
  components: {
    "v-detail": detail,
  },

}
</script>

<style scoped>
</style>
